home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Hardcore Visual Basic 5.0 (2nd Edition)
/
Hardcore Visual Basic 5.0 - Second Edition (1997)(Microsoft Press).iso
/
Code
/
ERRMSG.FRM
< prev
next >
Wrap
Text File
|
1997-06-14
|
3KB
|
93 lines
VERSION 5.00
Begin VB.Form FErrorMessage
Caption = "Look Up Error Messages"
ClientHeight = 2700
ClientLeft = 1260
ClientTop = 2265
ClientWidth = 4470
Icon = "ERRMSG.frx":0000
LinkTopic = "FErrorMsg"
PaletteMode = 1 'UseZOrder
ScaleHeight = 2700
ScaleWidth = 4470
Begin VB.TextBox txtMessage
Appearance = 0 'Flat
BackColor = &H00C0C0C0&
BorderStyle = 0 'None
Height = 1215
Left = 216
MultiLine = -1 'True
TabIndex = 2
Top = 1080
Width = 4092
End
Begin VB.TextBox txtError
Height = 495
Left = 228
TabIndex = 1
Text = "0"
Top = 384
Width = 1215
End
Begin VB.CommandButton cmdLookup
Caption = "&Lookup"
Default = -1 'True
Height = 495
Left = 1656
TabIndex = 0
Top = 384
Width = 1215
End
Begin VB.Label lbl
Caption = "Enter error number (decimal or hexadecimal):"
Height = 216
Left = 216
TabIndex = 3
Top = 48
Width = 3360
End
End
Attribute VB_Name = "FErrorMessage"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub cmdLookup_Click()
Dim iMsgId As Long, ret As Long, sVal As String
sVal = txtError
' Recognize leading & as a hex specifier without following H
If Left$(sVal, 1) = "&" And UCase$(Mid$(sVal, 2, 1)) <> "H" Then
sVal = "&H" & Mid$(sVal, 2)
End If
iMsgId = Val(sVal)
' Create the error message
Dim sNum As String, sMsg As String
sMsg = String$(256, 0)
ret = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM Or _
FORMAT_MESSAGE_IGNORE_INSERTS, _
0&, iMsgId, 0&, sMsg, Len(sMsg), ByVal pNull)
' Display it
sNum = "Error : " & iMsgId & " (&H" & Hex(iMsgId) & ")" & vbCrLf
If ret Then
txtMessage = sNum & vbCrLf & Left$(sMsg, lstrlen(sMsg))
Else
txtMessage = sNum & vbCrLf & "No such error"
End If
cmdLookup.SetFocus
txtError.SetFocus
End Sub
Private Sub Form_Activate()
txtError.SetFocus
End Sub
Private Sub txtError_GotFocus()
Debug.Print "Got Focus"
txtError.SelStart = 0
txtError.SelLength = 255
End Sub